// pages/personal/index.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    userInfo: undefined
  },
  toOrderPage(e){
    if(wx.getStorageSync('loginUser')){
      let status=  e.currentTarget.dataset.status
      wx.navigateTo({
        url: '/pages/order/index?status='+status,
      })
    }else{
      wx.navigateTo({
        url: '/pages/login/index',
      })
    }
   
  },
  gotoCart(){
    if(wx.getStorageSync('loginUser')){
      wx.navigateTo({
        url: "/pages/cart/index"
      })
    }else{
      wx.navigateTo({
        url: '/pages/login/index',
      })
    }
  },
  gotoCollects(){
    if(wx.getStorageSync('loginUser')){
      wx.navigateTo({
        url: "/pages/collect/index"
      })
    }else{
      wx.navigateTo({
        url: '/pages/login/index',
      })
    }
  },
  gotoAddress(){
    if(wx.getStorageSync('loginUser')){
      wx.navigateTo({
        url: '/pages/addressList/index',
      })
    }else{
      wx.navigateTo({
        url: '/pages/login/index',
      })
    }
  },
  toUserPage(){
    if(wx.getStorageSync('loginUser')){
      wx.navigateTo({
        url: '/pages/user/index',
      })
    }else{
      wx.navigateTo({
        url: '/pages/login/index',
      })
    }
  },
  handleContact (e) {
    console.log(e.detail.path)
    console.log(e.detail.query)
},
handleLogout(){
  wx.removeStorageSync('loginUser')
  this.setData({userInfo:undefined})
  wx.reLaunch({
    url: '/pages/personal/index',
  })
},
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {

  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {
    if (wx.getStorageSync('loginUser')) {
      let userInfo = wx.getStorageSync('loginUser')
      this.setData({
        userInfo: {
          nickName: userInfo.nickName,
          avatar: userInfo.avatar
        }
      })
    }
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})